@extends('admin::layouts.master')
@section('content')
    <div class="card" id="app">
        <div class="card-header">管理员管理</div>
        <ul role="tablist" class="nav nav-tabs">
            <li class="nav-item"><a href="/admin/manage" class="nav-link">管理员列表</a></li>
            <li class="nav-item"><a href="#" class="nav-link active">修改管理员</a></li>
        </ul>

        <form action="/admin/manage/{{$manage['id']}}" method="post">
            <div class="card-body card-body-contrast">
                @csrf
                @method('PUT')
                <input type="hidden" name="id" value="{{ $manage['id']??old('id') }}">

                <div class="form-group row">
                    <label for="name" class="col-12 col-sm-1 col-form-label text-md-right">姓名</label>
                    <div class="col-12 col-md-5">
                        <input id="name" name="name" type="text"
                               value="{{ $manage['name']??old('name') }}"
                               class="form-control form-control-sm form-control{{ $errors->has('name') ? ' is-invalid' : '' }}">
                        @if ($errors->has('name'))
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $errors->first('name') }}</strong>
                            </span>
                        @endif
                    </div>
                </div>

                <div class="form-group row">
                    <label for="nickname" class="col-12 col-sm-1 col-form-label text-md-right">昵称</label>
                    <div class="col-12 col-md-5">
                        <input id="nickname" name="nickname" type="text"
                               value="{{ $manage['nickname']??old('nickname') }}"
                               class="form-control form-control-sm form-control{{ $errors->has('nickname') ? ' is-invalid' : '' }}">
                        @if ($errors->has('nickname'))
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $errors->first('nickname') }}</strong>
                            </span>
                        @endif
                    </div>
                </div>

                <div class="form-group row">
                    <label for="password" class="col-12 col-sm-1 col-form-label text-md-right">密码</label>
                    <div class="col-12 col-md-5">
                        <input id="password" name="password" type="password"
                               value="{{ old('password') }}"
                               class="form-control form-control-sm form-control">
                        <div class="invalid-feedback" style="display: block;">添加操作必填，修改密码必填，其他非必要不填。</div>
                    </div>

                </div>

                <div class="form-group row">
                    <label for="gid" class="col-12 col-sm-1 col-form-label text-md-right">所在客服组</label>
                    <div class="col-12 col-md-5">
                        <select id="gid" name="gid" class="form-control form-control-xs">
                            <option value="">请选择客服组</option>
                            @foreach($chatgroups as $chatgroup)
                                <option value="{{$chatgroup['id']}}" @if($manage['gid'] == $chatgroup['id']) selected @endif>{{ $chatgroup['groupname'] }}</option>
                            @endforeach
                        </select>
                        <br>
                        @if ($errors->has('gid'))
                            <span class="text-danger">
                                <strong>{{ $errors->first('gid') }}</strong>
                            </span>
                        @endif
                    </div>
                </div>

                <div class="form-group row">
                    <label for="rolename" class="col-12 col-sm-1 col-form-label text-md-right">角色类型</label>
                    <div class="col-12 col-md-5">
                        <select id="rolename" name="rolename" class="form-control form-control-xs">
                            <option value="">请选择角色</option>
                            @foreach($roles as $role)
                                <option value="{{$role['name']}}" @if($manage->role[0]['title'] == $role['title']) selected @endif>{{ $role['title'] }}</option>
                            @endforeach
                        </select>
                        <br>
                        @if ($errors->has('rolename'))
                            <span class="text-danger">
                                <strong>{{ $errors->first('rolename') }}</strong>
                            </span>
                        @endif
                    </div>
                </div>
            </div>
            <div class="card-footer text-muted">
                <button class="btn btn-primary offset-sm-1">保存提交</button>
            </div>
        </form>
    </div>
@endsection
